import { defineStore } from 'pinia'
import { store } from '/@/store'
import type { AxiosResponse } from 'axios'
import type { Res } from '/@/tool/Res'
import type { Param } from '/@/tool/Param'
import type { DataExportAO } from '/@/model/cn/core/tool/ao/DataExportAO'

import computeTaskService from '/@/api/cn/core/kpis/computeTaskService'

import type { ComputeTask } from '/@/model/cn/core/kpis/eo/ComputeTask'
import type { ComputeTaskQO } from '/@/model/cn/core/kpis/qo/ComputeTaskQO'
import type { ComputeTaskVO } from '/@/model/cn/core/kpis/vo/ComputeTaskVO'

interface ComputeTaskState {
}

export const useComputeTaskStore = defineStore({
  id: 'computeTask',
  state: (): ComputeTaskState => ({
  }),
  getters: {
  },
  actions: {
    save(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.save(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    saveBatch(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.saveBatch(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    update(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.update(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    updateBatch(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.updateBatch(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    remove(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.remove(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    removeBatch(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.removeBatch(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    count(param: Param<ComputeTaskQO>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.count(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pk(param: Param<ComputeTaskQO>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.pk(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    query(param: Param<ComputeTaskQO>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.query(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    paging(param: Param<ComputeTaskQO>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.paging(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    countVo(param: Param<ComputeTaskQO>): Promise<Res<ComputeTaskVO>> {
      return new Promise<Res<ComputeTaskVO>>((resolve, reject) => {
        computeTaskService.countVo(param).then((res: AxiosResponse<Res<ComputeTaskVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pkVo(param: Param<ComputeTaskQO>): Promise<Res<ComputeTaskVO>> {
      return new Promise<Res<ComputeTaskVO>>((resolve, reject) => {
        computeTaskService.pkVo(param).then((res: AxiosResponse<Res<ComputeTaskVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    queryVo(param: Param<ComputeTaskQO>): Promise<Res<ComputeTaskVO>> {
      return new Promise<Res<ComputeTaskVO>>((resolve, reject) => {
        computeTaskService.queryVo(param).then((res: AxiosResponse<Res<ComputeTaskVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    pagingVo(param: Param<ComputeTaskQO>): Promise<Res<ComputeTaskVO>> {
      return new Promise<Res<ComputeTaskVO>>((resolve, reject) => {
        computeTaskService.pagingVo(param).then((res: AxiosResponse<Res<ComputeTaskVO>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataImport(param: Param<string>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.dataImport(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    dataExport(param: Param<DataExportAO<ComputeTaskQO>>): Promise<Res<string>> {
      return new Promise<Res<string>>((resolve, reject) => {
        computeTaskService.dataExport(param).then((res: AxiosResponse<Res<string>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
    compute(param: Param<ComputeTask>): Promise<Res<ComputeTask>> {
      return new Promise<Res<ComputeTask>>((resolve, reject) => {
        computeTaskService.compute(param).then((res: AxiosResponse<Res<ComputeTask>>) => {
          resolve(res.data)
        }).catch(err => {
          reject(err)
        })
      })
    },
  },
})

export function useComputeTaskStoreWithout() {
  return useComputeTaskStore(store)
}
